<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class veh_decommission_edit extends Page
{
       public $dpEnd = null;
       public $Label1 = null;
       public $imgBack = null;
       public $Image2 = null;
       public $hfAutoid = null;
       public $hfVeh = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $memoReason = null;
       public $dpdate = null;
       public $lblLastOdometer = null;
       public $lblDate = null;
       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function btnSubmitClick($sender, $params)
       {
       $query_up = "UPDATE veh_decommission SET
       dec_date='".$this->dpdate->getText()."',
       end_date='".$this->dpEnd->getText()."',
       reason='".$this->memoReason->Text."'
       WHERE autoid='".$this->hfAutoid->getValue()."'";
       mysql_query($query_up) or die("UPDATE ".mysql_error());

       redirect('veh_decommission_list.php?veh='.$this->hfVeh->getValue());
       }

       function veh_decommission_editCreate($sender, $params)
       {
       $this->hfAutoid->setValue($_GET['autoid']);
       $this->hfVeh->setValue($_GET['veh']);

       if($_SESSION["access_vehicle"]==1)
       {
       $this->btnSubmit->setVisible(false);
       $this->btnCancel->setVisible(false);
       }
       if($_SESSION["access_vehicle"]==2)
       {
       $this->btnSubmit->setVisible(true);
       $this->btnCancel->setVisible(true);
       }

       $autoid = $this->hfAutoid->getValue();

       $query_select = "SELECT dec_date,end_date,reason FROM veh_decommission WHERE autoid='".$autoid."'";
       $result_select = mysql_query($query_select) or die("SELECT ".mysql_error());
       $row_select = mysql_fetch_array($result_select);

       $this->dpdate->Text = $row_select['dec_date'];
       $this->dpEnd->Text = $row_select['end_date'];
       $this->memoReason->Lines = array();
       $this->memoReason->Text = $row_select['reason'];

       $this->imgBack->setLink('veh_decommission_list.php?veh='.$this->hfVeh->getValue());
       }

       function btnCancelJSClick($sender, $params)
       {

       ?>
       var veh = document.getElementById('hfVeh').value;
       window.location.href = 'veh_decommission_list.php?veh='+veh;
       <?php

       }

}

global $application;

global $veh_decommission_edit;

//Creates the form
$veh_decommission_edit=new veh_decommission_edit($application);

//Read from resource file
$veh_decommission_edit->loadResource(__FILE__);

//Shows the form
$veh_decommission_edit->show();

?>